package com.example.booklist.enums;

/**
 * ClassName: BookStatus
 * Package: IntelliJ IDEA
 * Description:
 *
 * @Author 谷京京
 * @Create 2023/11/20 19:45
 * @Version 1.0
 */
public enum BookStatus {
    DELETED(0, "删除"),
    NORMAL(1, "可借阅"),
    FORBIDDEN(2, "不可借阅")
    ;
    private int code;
    private String name;

    BookStatus(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public static BookStatus getNameByCode(int code) {
        switch (code) {
            case 0:return BookStatus.DELETED;
            case 1:return BookStatus.NORMAL;
            case 2:return BookStatus.FORBIDDEN;
            default:return BookStatus.FORBIDDEN;
        }
    }
}
